package com.cike.sparkstudy.sql.java;

import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.sql.DataFrame;
import org.apache.spark.sql.SQLContext;


/**
 * 通用的save和load操作
 */
public class GenericLoadSave {
    public static void main(String[] args){
        SparkConf conf = new SparkConf()
                .setMaster("local")
                .setAppName("GenericLoadSave");
        JavaSparkContext sc = new JavaSparkContext(conf);
        SQLContext sqlContext = new SQLContext(sc);

        DataFrame userDF = sqlContext.read().load("/developerCodes/test/users.parquet");

        userDF.select("name").write().save("/developerCodes/test/namesAndFavColors.parquet");

        //sqlContext.read().load("/developerCodes/test/namesAndFavColors.parquet/part-r-00000-287a8634-60a7-4dbb-b9cc-2cac418a4fca.gz.parquet").show();
    }
}
